from pyramid.response import Response
from pyramid.view import view_config

students = [
    {"id": 1, "name": "Ravi", "percent": 75},
    {"id": 2, "name": "Mona", "percent": 80},
    {"id": 3, "name": "Mathews", "percent": 45},
]


class FormsView:
    def __init__(self, request):
        self.request = request

    @view_config(route_name='index', renderer='./templates/myform.html')
    def index(self):
        return {}

    @view_config(route_name='students', renderer='./templates/marklist.html')
    def add(self):
        student = {'id': self.request.params['id'], 'name': self.request.params['name'],
                   'percent': int(self.request.params['percent'])}
        students.append(student)
        return dict(students=students)
